import { GCellRenderer } from "../../../../../com/mui/controls/GCellRenderer";
import { PetMingItemData } from "../info/PetMingItemData";
import { PetMingBagBaseItem } from "./PetMingBagBaseItem";
import { DragEvent } from "../../../../../com/mui/events/DragEvent";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { PetMingBaseItem } from "./PetMingBaseItem";
import { ItemsUtil } from "../../shortcuts/item/ItemsUtil";
import { EPlayerItemPosType } from "../../../../../Message/Public/EPlayerItemPosType";
import { Cache } from "../../../cache/Cache";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
//class PetMingBagCellRenderer
    
    export  class PetMingBagCellRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this.init();
            this.doubleClickEnabled = true;
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            this._itemData = arg1 as PetMingItemData;
            this._mingBaseItem.itemData = this._itemData;
            return;
        }

        /* internal  */init(): void
        {
            this._bg = new Object /* flash.display.Bitmap */();
            this.addChild(this._bg);
            this._mingBaseItem = new PetMingBagBaseItem();
            this._mingBaseItem.x = -5;
            this._mingBaseItem.y = -5;
            this._mingBaseItem.addEventListener(DragEvent.Event_Move_In, this.onMoveInHandler);
            this.addChild(this._mingBaseItem);
            LoaderHelp.addResCallBack(ResFileConst.PetMing, this.onLoadedHandler);
            return;
        }

        /* internal  */onLoadedHandler(): void
        {
            this._bg.bitmapData = GlobalClass.getBitmapData(ImagesConst.PetMingAvatarBg);
            return;
        }

        /* internal  */onMoveInHandler(arg1: DragEvent): void
        {
            var loc3=null;
            var loc1=arg1.dragItem as PetMingBaseItem;
            var loc2=arg1.dragSouce as PetMingItemData;
            if (loc2 && ItemsUtil.isPetLifeStyle(loc2)) 
            {
                if (loc1.posType == EPlayerItemPosType._EPlayerItemPosTypePetEquipBase) 
                {
                    if (loc3 = Cache.instance.petMing.currentPetInfo) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.PetMingUnDress, {"petUid": loc3.uid, "bagUid": loc2.uid}));
                    }
                }
            }
            return;
        }

        /* internal */ /* var */_bg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_mingBaseItem: PetMingBagBaseItem;

        /* internal */ /* var */_itemData: PetMingItemData;
    }
